package com.fr.base.file;

import com.fr.base.XMLFileManager;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLReadable;
import com.fr.base.xml.XMLableReader;
import com.fr.report.io.xml.SynchronizedVersion;
import com.fr.web.face.FaceNode;
import com.fr.web.face.NodeDef;

public class FaceManager extends XMLFileManager
{
  private FaceNode rootFaceNode = new FaceNode();
  private int dayOfMonth = 7;
  private boolean outlookView = true;
  private boolean showHomePage = true;
  private boolean homeTabClosable = false;
  private String homeTitle = "FineReport Demo";
  private String homeURLPath = null;

  public String fileName()
  {
    return "face.xml";
  }

  public int getDayOfMonth()
  {
    return this.dayOfMonth;
  }

  public void setDayOfMonth(int paramInt)
  {
    this.dayOfMonth = paramInt;
  }

  public FaceNode getRootFaceNode()
  {
    return this.rootFaceNode;
  }

  public void setRootFaceNode(FaceNode paramFaceNode)
  {
    this.rootFaceNode = paramFaceNode;
  }

  public boolean isOutlookView()
  {
    return this.outlookView;
  }

  public void setOutlookView(boolean paramBoolean)
  {
    this.outlookView = paramBoolean;
  }

  public boolean isShowHomePage()
  {
    return this.showHomePage;
  }

  public void setShowHomePage(boolean paramBoolean)
  {
    this.showHomePage = paramBoolean;
  }

  public boolean isHomeTabClosable()
  {
    return this.homeTabClosable;
  }

  public void setHomeTabClosable(boolean paramBoolean)
  {
    this.homeTabClosable = paramBoolean;
  }

  public String getHomeTitle()
  {
    return this.homeTitle;
  }

  public void setHomeTitle(String paramString)
  {
    this.homeTitle = paramString;
  }

  public String getHomeURLPath()
  {
    return this.homeURLPath;
  }

  public void setHomeURLPath(String paramString)
  {
    this.homeURLPath = paramString;
  }

  public NodeDef searchNodeDef(String[] paramArrayOfString)
  {
    if ((paramArrayOfString == null) || (paramArrayOfString.length <= 0))
      return null;
    Object localObject = getRootFaceNode();
    for (int i = 0; i < paramArrayOfString.length; ++i)
    {
      int j = ((FaceNode)localObject).getChildCount();
      for (int k = 0; k < j; ++k)
      {
        FaceNode localFaceNode = ((FaceNode)localObject).getChild(k);
        NodeDef localNodeDef = localFaceNode.getNodeDef();
        if (ComparatorUtils.equals(localNodeDef.getName(), paramArrayOfString[i]))
        {
          localObject = localFaceNode;
          break;
        }
      }
    }
    if ((localObject != null) && (localObject != getRootFaceNode()))
      return ((FaceNode)localObject).getNodeDef();
    return ((NodeDef)null);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str1;
      Object localObject;
      String str2 = paramXMLableReader.getTagName();
      if (str2.equals("XMLVersion"))
      {
        if ((str1 = paramXMLableReader.getElementValue()) != null)
        {
          localObject = SynchronizedVersion.getSynchronizedVersion(Thread.currentThread());
          ((SynchronizedVersion)localObject).setXmlVersionByString(str1);
        }
      }
      else if ("Attributes".equals(str2))
      {
        if ((str1 = paramXMLableReader.getAttr("dayOfMonth")) != null)
          setDayOfMonth(Integer.parseInt(str1));
        if ((str1 = paramXMLableReader.getAttr("outlookView")) != null)
          setOutlookView(Boolean.valueOf(str1).booleanValue());
        if ((str1 = paramXMLableReader.getAttr("showHomePage")) != null)
          setShowHomePage(Boolean.valueOf(str1).booleanValue());
        if ((str1 = paramXMLableReader.getAttr("homeTabClosable")) != null)
          setHomeTabClosable(Boolean.valueOf(str1).booleanValue());
        if ((str1 = paramXMLableReader.getAttr("homeTabTitle")) != null)
          setHomeTitle(str1);
        if ((str1 = paramXMLableReader.getAttr("homeURLPath")) != null)
          setHomeURLPath(str1);
      }
      else if ("FaceNode".equals(str2))
      {
        localObject = new FaceNode();
        setRootFaceNode((FaceNode)localObject);
        paramXMLableReader.readXMLObject((XMLReadable)localObject);
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("FaceManager");
    paramXMLPrintWriter.startTAG("Attributes").attr("dayOfMonth", getDayOfMonth());
    if (!(isOutlookView()))
      paramXMLPrintWriter.attr("outlookView", isOutlookView());
    if (!(isShowHomePage()))
      paramXMLPrintWriter.attr("showHomePage", isShowHomePage());
    if (isHomeTabClosable())
      paramXMLPrintWriter.attr("homeTabClosable", isHomeTabClosable());
    if (getHomeTitle() != null)
      paramXMLPrintWriter.attr("homeTabTitle", getHomeTitle());
    if (getHomeURLPath() != null)
      paramXMLPrintWriter.attr("homeURLPath", getHomeURLPath());
    paramXMLPrintWriter.end();
    FaceNode localFaceNode = getRootFaceNode();
    if (localFaceNode != null)
      localFaceNode.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.end();
  }
}